import java.util.Scanner;

/**
 * @author wzby
 * @Date: 2022/8/4 20:53
 */
public class Scan2 {
    public static void main(String[] args) {
        System.out.println("===猜数游戏===");
        Scanner sc = new Scanner(System.in);
         while (true){
             System.out.print("请输入数字： ");
             int i = 0;
             if (sc.hasNextInt()){
                 i = sc.nextInt();
                 //hasNextInt有没有输入整数
             }else{
                 sc.nextLine();
                 System.out.println("输入错误，请重新输入");
                 continue;
             }
             if (i == 42){
                 System.out.println("猜对了");
                 break;
             }else {
                 System.out.println("猜错了");
             }
         }
    }
}
